/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.core.editpart;

import java.util.Iterator;
import java.util.List;

import org.eclipse.gef.DragTracker;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.Handle;
import org.eclipse.gef.editpolicies.ResizableEditPolicy;
import org.eclipse.gef.handles.MoveHandle;

/**
 * 
 */
public class ElementResizableEditPolicy extends ResizableEditPolicy
	{

	/**
	 * Provides a specific list of SelectionHandles.
	 * 
	 * @return a list of the Handles
	 */
	// this operation is overidden to adress the issue of MoveHandle
	// (i.e. the edit part is moved using the "cross")
	protected List createSelectionHandles(){
		List list = super.createSelectionHandles() ;
		for (Iterator<Handle> i = list.iterator(); i.hasNext() ; ) {
			Handle handle = i.next() ;
			if (handle instanceof MoveHandle) {
				DragTracker dragTracker = ((GraphicalEditPart)getHost()).getDragTracker(null) ;
				((MoveHandle)handle).setDragTracker(dragTracker) ;
			}
		}
		return list ;
	}
		
}
